package com.tanran.es.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import java.util.Date;


/**
 * Created by Enzo Cotter on 2019/12/26.
 * useServerConfiguration = true 使用线上的配置,
 * createIndex 在项目启动的时候不要创建索引，通常在 kibana 中已经配置过了
 */
@Data
@Document(indexName = "blog" ,type = "_doc" ,useServerConfiguration = true,createIndex = false)

public class EsBlog {
    @Id
    private Long id;
    /**
     * 图片地址
     */
    @Field(type = FieldType.Text)
    private String images;
    /**
     * 来源id
     */
    @Field( type = FieldType.Long)
    @JsonProperty("resource_id")
    private Long resourceId;
    /**
     * 来源
     */
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String resource;
    /**
     * 商城
     */
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String mall;
    /**
     * 标题
     */
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String title;
    /**
     * 作者
     */
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    @JsonProperty("user_name")
    private String userName;
    /**
     * 内容
     */
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    @Column(columnDefinition = "longtext")
    private String content;
    /**
     * 真实地址
     */
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String url;
    /**
     * 创建时间
     */
    @Field(type = FieldType.Date)
    @JsonProperty("create_time")
    /**
     * 暂时没有办法 下划线的处理
     */
    private Date createTime;
}
